package com.springcloud.tread.controller;

import com.springcloud.tread.pojo.IndexData;
import com.springcloud.tread.service.IndexDataClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class IndexDataController {

    @Autowired
    IndexDataClientService indexDataClientService;

    @GetMapping("/customer/get/{id}")
    @CrossOrigin//支持跨域请求，因为请求使用的是一个端口，而资源又是另外一个端口
    public Map<String, List<IndexData>> get( @PathVariable String id) {
        List<IndexData> indexDatas = indexDataClientService.getIndexData(id);
        Map<String,List<IndexData>> maps= new HashMap<>();
        maps.put("indexDatas",indexDatas);
        return maps;
    }


}
